#pragma once
#ifndef __GLOBE_H_
#define __GLOBE_H_

#include <string>
#include <vector>
#include "mtxlib.h"
#include "MultiTouchData.h"

class Globe
{
private:
  std::string _name;
  std::wstring _textureName;
  unsigned int _sliceNum;
  float _radius;

  Matrix44 _rotateMatrix;
  Matrix44 _rotateReverseMatrix;
  Vector3f _lastAxis;
  Vector2f _lastPoint;
  Vector2f _currentPoint;

  float _autoRotateAngle;
  float _autoRotateCurAngle;
  float _autoRotateCurSpeed;
  Vector3f _autoRotateAxis;

  MultiTouchData _multiTouchData;

	void _createGlobe ();
  void _drawVertex (float longitudeRad, float latitudeRad);
  void _rotateGlobe (Vector2f src,Vector2f des);
  void _rotateGlobe (Vector3f axis, float angle);

public:
  enum { NORMAL, AUTO_ROTATE } status;

	Globe ();

  void render ();
  void touch (std::vector< Vector3f >& pointsInRectangular);
  void rotateTo (float longitude, float latitude);
  void doAnimation ();

  std::wstring getTexture () const { return _textureName; }
  void setTexture (const std::wstring& textureName) { _textureName = textureName; }

  const Matrix44& getRotateMatrix () const { return _rotateMatrix; }
  const Matrix44& getReverseMatrix () const { return _rotateReverseMatrix; }
};

#endif